﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sasc.PV.BLL;
using Sasc.PV.DAL;

namespace Sasc.PV.Web.Admin.SystemManage
{
    public partial class BuMenInfoAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //提交
        protected void SubmitImageButton_Click(object sender, ImageClickEventArgs e)
        {
            if (PublicMethod.IFExists("BuMenName", "ERPBuMen", 0, this.TextBox1.Text) == true)
            {
                ERPBuMen MyBuMen = new ERPBuMen();
                MyBuMen.BuMenName = this.TextBox1.Text;
                MyBuMen.ChargeMan = this.TextBox2.Text;
                MyBuMen.TelStr = this.TextBox3.Text;
                MyBuMen.ChuanZhen = this.TextBox4.Text;
                MyBuMen.BackInfo = this.TextBox5.Text;
                MyBuMen.DirID = int.Parse(Request.QueryString["DirID"].ToString());
                MyBuMen.Add();

                //写系统日志
                ERPRiZhi MyRiZhi = new ERPRiZhi();
                MyRiZhi.UserName =PublicMethod.GetSessionValue("UserName");
                MyRiZhi.DoSomething = "用户添加部门信息(" + this.TextBox1.Text + ")";
                MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
                MyRiZhi.Add();

                MessageBox.ShowAndRedirect(this, "部门信息添加成功！", "BuMenInfo.aspx?View=" + Request.QueryString["View"].ToString() + "&Type=" + Request.QueryString["Type"].ToString() + "&DirID=" + Request.QueryString["DirID"].ToString());
            }
            else
            {
                MessageBox.Show(this, "该部门已经存在，请更换名称！");
            }

        }
    }
}